Skip to content

Improve iOS Label performance#30864

Closed
albyrock87 wants to merge 1 commit into
dotnet:mainfrom
albyrock87:ios-label-handler-perf-impr
Closed

Improve iOS Label performance#30864
albyrock87 wants to merge 1 commit into
dotnet:mainfrom
albyrock87:ios-label-handler-perf-impr

Conversation

@albyrock87
Copy link
Copy Markdown
Contributor

@albyrock87 albyrock87 commented Jul 27, 2025

Description of Change

This PR contributes on improving what's reported in #30721 regarding iOS.

Label is a fundamental component of all applications, and by looking at the provided speedscope I noticed that MapText was taking a lot.

The reason is (as usual) useless mapping calls.

image

@albyrock87 albyrock87 requested a review from a team as a code owner July 27, 2025 11:43
@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Jul 27, 2025
@PureWeen
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz jsuarezruiz added area-controls-label Label, Span perf/general The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf) labels Jul 28, 2025
if (!handler.IsConnectingHandler())
{
// Any text update requires that we update any attributed string formatting
MapFormatting(handler, label);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check also if is invoked more than once?

EntryHandler.MapFormatting(handler, entry);

We could review and could be a good optimization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz indeed, it was also mapping the text twice!

Also thanks a lot to @bhavanesh2001 for pointing out how LabelHandler.iOS is never called due to the code in Label.Mapper.cs (same thing on Entry.Mapper.cs).

I will update the perf numbers in the PR description soon.

@albyrock87 albyrock87 force-pushed the ios-label-handler-perf-impr branch from 8bf87e2 to 1fcf8c2 Compare July 28, 2025 08:11

public static void MapFormatting(IEntryHandler handler, IEntry entry)
{
handler.PlatformView?.UpdateMaxLength(entry);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't taking into consideration that a developer can provide their own mappers.

@rmarinho rmarinho added this to the .NET 9 SR10 milestone Jul 30, 2025
@PureWeen
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen modified the milestones: .NET 9 SR10, .NET 9 SR11 Aug 4, 2025
@PureWeen PureWeen moved this from Todo to Changes Requested in MAUI SDK Ongoing Aug 4, 2025
Comment on lines +34 to +38
[nameof(IEntry.Font)] = MapFont,
[nameof(IEntry.MaxLength)] = MapMaxLength,
[nameof(IEntry.HorizontalTextAlignment)] = MapHorizontalTextAlignment,
[nameof(IEntry.VerticalTextAlignment)] = MapVerticalTextAlignment,
[nameof(IEntry.CharacterSpacing)] = MapCharacterSpacing,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatted with @albyrock87

Fix this by adding a second mapper to enforce a more intentional ordering

@albyrock87 albyrock87 force-pushed the ios-label-handler-perf-impr branch from 1fcf8c2 to a95b708 Compare August 9, 2025 19:53
@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Aug 10, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@jfversluis
Copy link
Copy Markdown
Member

/rebase

@jfversluis jfversluis force-pushed the ios-label-handler-perf-impr branch from a95b708 to a5f3531 Compare September 2, 2025 14:37
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Copy Markdown
Member

closing in favor of #31159

@PureWeen PureWeen closed this Sep 10, 2025
@github-project-automation github-project-automation Bot moved this from Changes Requested to Done in MAUI SDK Ongoing Sep 10, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-label Label, Span community ✨ Community Contribution partner/syncfusion/review perf/general The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants